package receiver;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ita.ios.jms.protocol.JmsProtocol;

import po.ComplaintAudit;
import service.ComplaintAuditManager;
import vo.OrderComplaintVo;

 
@Component("orderComplainListener")
public class OrderComplaintListener implements MessageListener {

	@Autowired
	private ComplaintAuditManager complaintAuditManager;
	
	@Override
	public void onMessage(Message message) {
		try {
			String text = ((TextMessage)message).getText();
			System.out.println("orderComplainListener接收到消息:" + text);
			ComplaintAudit complaintAudit = (ComplaintAudit) JmsProtocol.deserializeObject(text, ComplaintAudit.class);
			if(complaintAudit != null){
				complaintAuditManager.addComplaint(complaintAudit);
				System.out.println("add the orderComplain success!!!");
			}
		} catch (JMSException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
